<!DOCTYPE html>
<html>
<head>
    <title>参数编辑</title>
    {% include 'system/common/header.html' %}
</head>
<body>
    <form class="layui-form">
        <div class="mainBox">
            <div class="main-container">
                    <div class="layui-form-item">
                        <input type="hidden" name="id" value="{{ webdata.id }}">
                        <label class="layui-form-label">参数名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="key_name" lay-verify="title" autocomplete="off"
                                placeholder="请使用英文字母，不可使用特殊字符" class="layui-input" value="{{ webdata.key_name }}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">参数值</label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容" class="layui-textarea" name="value_name" >{{ webdata.value_name }}</textarea>
                            <!-- <input type="text" name="value_name" lay-verify="title" autocomplete="off" placeholder="请输入参数"
                                class="layui-input" vlaue="'{{ webdata.value_name }}'">  -->
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">备注</label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容" class="layui-textarea" name="remark" >{{ webdata.remark }}</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-block">
    
                            <input type="radio" name="enable" {% if webdata.enable == 1 %}checked{% endif %} value="1"
                                   title="开启">
    
                            <input type="radio" name="enable" {% if webdata.enable == 0 %}checked{% endif %} value="0"
                                   title="关闭"
                            >
                        </div>
                    </div>
                
            </div>
        </div>
        <div class="bottom">
            <div class="button-container">
                <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="web-update">
                    <i class="layui-icon layui-icon-ok"></i>
                    提交
                </button>
                <button type="reset" class="pear-btn pear-btn-sm">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
        </div>
    </form>
{% include 'system/common/footer.html' %}
<script>
    layui.use(['form', 'jquery'], function () {
    let form = layui.form
    let $ = layui.jquery
      
    //   let MODULE_PATH = '/admin/system/site/'
    let MODULE_PATH = "{{ url_for('system.site.main') }}"
      form.on('submit(web-update)', function (data) {
        let loading = layer.load()
        let formData = data.field;
        $.ajax({
          url: MODULE_PATH + 'update',
          data: JSON.stringify(data.field),
          dataType: 'json',
          contentType: 'application/json',
          type: 'post',
          success: function (result) {
            layer.close(loading)
            if (result.success) {
              layer.msg(result.msg, { icon: 1, time: 1000 }, function () {
                parent.layer.close(parent.layer.getFrameIndex(window.name))//关闭当前页
                parent.layui.table.reload('web-dataTable')
              })
            } else {
              layer.msg(result.msg, { icon: 2, time: 1000 })
            }
          }
        })
        // console.log(data.field)
        return false
      })
    })
  </script>
</body>
</html>